
//判断用户登陆后，如果在frame子页面内session超时将返回父页面登陆页面
function  returnLoginPage(){			
	var selfUrl = self.location+"";
	var topUrl = top.location+"";				
	var arr=new Array();	
	arr=selfUrl.split("/");	
	if(arr.length>0){
		var lastNode=arr[arr.length-1];					
		if(lastNode =="login.jsp" && selfUrl != topUrl){	
			top.location.href='mgr/mgrMain.jsp';
		}
	}
}
		

//显示模态窗口
function lockedPage()
{
   var a = "image/large-loading.gif";
   var floatDiv = window.document.createElement("div");
   var width = window.document.body.clientWidth;
   var height= window.document.body.clientHeight;
   with(floatDiv) {
	  id  = "floatDiv";
      style.cssText = "Z-INDEX: 500; LEFT: 0px; WIDTH: "+ width +"px; POSITION: absolute; TOP: 0px; HEIGHT: "+ height +"px; border:1px solid #E7EFEF; background-color:#E7EFEF;filter:alpha(opacity=85);";
      innerHTML="<div style='float:left;position:fixed;_position:absolute;left:38%;top:42%;' align='center'><center><img src='"+a+"' style='margin-right:8px;float:left;vertical-align:top;'/></center></div><div style=position:absolute;left:40%;top:49%><font color='blue' size='3px'>正在加载中，请稍后。。。</font></div>";
   }
   window.document.body.appendChild(floatDiv);
}

//去除模态窗口
function unlockPage(){
	var div1=window.document.getElementById('floatDiv');
	window.document.body.removeChild(div1);
}

//登陆js
function loginPage() {
	var isTrue;
	var userName=$("#userName").val();
	var userPassword=$("#userPassword").val();
	if(""==userName || ""==userPassword){
	 	alert("帐号和密码不能为空");
	}else{
	    lockedPage();
		url = "login_jsLogin?userName="+userName+"&userPassword="+userPassword;
		var str= "a=" + Math.random() * 1000;
		url=url+"&"+str; 
		$.post(url,null,function(data){
			if(data != 'OK'){
				unlockPage();
				alert(data);
			}else{
				window.location="mgr/mgrMain.jsp?"+str;
			}
        }, "text");
	}
}

//回车提交事件
document.onkeydown = function(e){
    if(!e) e = window.event;//火狐中是 window.event
    if((e.keyCode || e.which) == 13){
        loginPage();
    }
}